var objs = {
	baseUrlWin: $("#baseUrlWin"),
	baseUrlForm: $("#baseUrlForm"),
	envId: $("#envId"),
	taskIdInput: $("#taskIdInput")
};

$(function(){
	$.parser.parse();
	objs.taskIdInput.val(taskId);
	loadBaseUrl();
});

// 加载baseURL数据
function loadBaseUrl() {
	$.get(
		baseUrl + '/apiManager/envVarAction!findOne.action',
		{
			'dto.apiEnvVar.taskId': taskId,
			'dto.apiEnvVar.type': 9
		}, function(data, status, xhr){
			if(status == 'success'){
				objs.baseUrlForm.xdeserialize(data);
			}
		}, 'json'
	);
}

// 提交保存
function save() {
	var valid = objs.baseUrlForm.xform('validate');
	if (!valid) {
		return;
	}
	
	var url = baseUrl + '/apiManager/envVarAction!saveOrUpdate.action';
	var data = objs.baseUrlForm.xserialize();
	var msg = objs.envId.val() ? '修改成功' : '保存成功';
	$.post(url,data,function(res) {
		if ('success' == res.successFailed) {
			objs.baseUrlWin.xwindow('close');
			$.xnotify(msg, {type: 'success'});
		} else {
			$.xnotify('系统错误！', {type: 'warning'});
		}
	}, 'json');
}

// 取消关闭弹窗
function closeWin() {
	objs.baseUrlWin.xwindow('close');
}